package com.bishe.psy.controller;

import com.bishe.psy.common.AppResult;
import com.bishe.psy.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: L
 * Date: 2024-03-21
 * Time: 19:28
 */
@Api(tags = "测试类的相关接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试接口1，抛出一个Exception异常")
    @GetMapping("/exception")
    public AppResult exception() throws Exception {
        throw new Exception("这是一个exception");
    }

    @ApiOperation("测试接口2，抛出一个appException异常")
    @GetMapping("/appException")
    public AppResult appException() {
        throw new ApplicationException("这是一个ApplicationException");
    }

    @ApiOperation("测试接口3，显示hello + name")
    @PostMapping("/helloByname")
    public String helloByname(@ApiParam(value = "姓名") @RequestParam("name") String name) {
        return "hello:" + name;
    }
}
